'use strict';
import inquirer from 'inquirer';

export const INQUIRER_TYPE = "list"

const make = ({
                  choices,
                  defaultValue,
                  validate,
                  pageSize,
                  loop,
                  type = INQUIRER_TYPE,
                  message = "请选择",
                  require = true,
                  mask = "*"
              }) => {
    const options = {name: 'name', default: defaultValue, message, type, require, mask, validate, pageSize, loop,}
    type === INQUIRER_TYPE && (options.choices = choices)
    return inquirer.prompt(options).then(a => a.name)
}

export const makeList = (params) => make({...params});

export const makeInput = (params) => make({type: 'input', ...params,});

export const makePassword = (params) => make({type: 'password', ...params,});
